Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only inserted fields #719

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lxfeng1997
Copy link
Contributor

What this PR does:
optimize: only the inserted fields are checked

Which issue(s) this PR fixes:
#697

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Copy link

sonarcloud bot commented Dec 5, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
20.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

selectFieldsStr = strings.Join(meta.ColumnNames, ",")
}

sb.WriteString("SELECT " + selectFieldsStr + " FROM " + meta.TableName + " ")
Copy link
Contributor

@luky116 luky116 Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insert_test 单元测试得修改下

@@ -184,9 +184,12 @@ func (i *insertExecutor) buildAfterImageSQL(ctx context.Context) (string, []driv
}
// build check sql
sb := strings.Builder{}
sb.WriteString("SELECT * FROM " + tableName)
suffix := strings.Builder{}
sb.WriteString("SELECT " + strings.Join(pkColumnNameList, ", "))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里只 select 主键字段吗?应该是选择 insert 中带的字段比较合理?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,除了要把 insert 的字段查出来,还需要把有默认值的字段也查出来?这些字段的修改也可能导致脏回滚

@@ -132,9 +132,12 @@ func (u *MySQLInsertUndoLogBuilder) buildAfterImageSQL(ctx context.Context, exec
}
// build check sql
sb := strings.Builder{}
sb.WriteString("SELECT * FROM " + tableName)
suffix := strings.Builder{}
sb.WriteString("SELECT " + strings.Join(pkColumnNameList, ", "))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同理如上

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants